<template>
    <common-header />
    <div class="member-bpus-index">
        <div class="slider">
            <ul class="sidebar-menu list-unstyled" style="display: block">
                <li class="sidebar-list-item">
<!--                    <router-link class="sidebar-link text-muted" to="/member/sy" active-class="active1"> 个人中心 </router-link>-->
                </li>
                <li class="sidebar-list-item" v-for="(r,k) in menus" :key="k">
                    <a href="javascript:;" class="sidebar-link text-muted">
                        <i class="mr5" :class="r.icon ? r.icon : 'el-icon-user'"></i>
                        <span>{{ r.label }}</span>
                        <span class="arrow el-icon-caret-right"></span>
                    </a>
                    <ul class="sidebar-menu list-unstyled sidebar-submenu" style="">
                        <li v-for="(v,j) in r.children" :key="j">
                            <router-link class="sidebar-link text-muted pl-lg-5" :to="v.to" exact-active-class="active1"> {{ v.label }} </router-link>
                        </li>
                    </ul>
                </li>
            </ul>
        </div>
        <div class="content-main">
            <router-view></router-view>
        </div>
    </div>
    <common-footer />
</template>
<script>
    export default {
        name: "",
    };
</script>
<script setup>
    import CommonHeader from "@/views/header.vue";
    import CommonFooter from "@/views/footer.vue";
    import menu from "@/views/admin/sidebar/index";
    import { useRoute } from "vue-router";
    import { ref } from "vue";
    import { isObject } from "@/utils";

    const route = useRoute();
    const menus = ref([]);
    const active = ref(-1);
    menu.getMenus().then((res) => {
        var menus1 = res;
        var active1 = -1;
        var path = route.path;

        for (var i in menus1) {
            var ci = menus1[i];
            for (var j in ci.children) {
                var v = ci.children[j];
                var vPath = "";
                if (isObject(v.to)) {
                    // 对象
                    vPath = v.to.path = v.to.path.replace("/admin/", "/member/");
                } else {
                    vPath = v.to = v.to.replace("/admin/", "/member/");
                }
                if (vPath == path) {
                    active1 = i;
                    break;
                }
            }
            if (active1 != -1) break;
        }
        if (active1 != -1) {
            active.value = active1;
        }
        menus.value = menus1;
    });
</script>
<style scoped lang="scss">
    $sliderWidth: 225px;
    .member-bpus-index {
        margin: 20px auto;
        position: relative;
        display: flex;
        max-width: 1300px;
        .pl-lg-5 {
            padding-left: 3rem !important;
        }
        .slider {
            flex-shrink: 0;
            width: $sliderWidth;
            background: #ffffff;
            box-shadow: 2px 0 5px #a3a3a3;
            padding: 15px 0;
            overflow: hidden;
            overflow-y: auto;
            margin-right: 10px;
            .list-unstyled {
                padding-left: 0;
                list-style: none;
            }
            .sidebar-submenu {
                padding: 10px 0;
            }
            .sidebar-menu {
                .sidebar-link {
                    display: -webkit-box;
                    display: -ms-flexbox;
                    display: flex;
                    align-items: center;
                    transition: background 0.3s;
                    padding: 0.5rem 1.5rem;
                    .arrow {
                        position: absolute;
                        right: 15px;
                    }
                }
                .sidebar-link:hover {
                    text-decoration: none;
                    background: #f5f5f5;
                }
                .sidebar-link.active,
                .sidebar-link:focus {
                    background: #4680ff;
                    color: #fff !important;
                    text-decoration: none;
                }
                .sidebar-link.active1 {
                    background-color: rgba(71, 129, 255, 0.81);
                    color: #fff !important;
                    text-decoration: none;
                }
                .text-muted {
                    color: #6c757d !important;
                }
            }
        }
        .content-main {
            min-height: 500px;
            background: #FFFFFF;
            box-shadow: 2px 0 5px #a3a3a3;
            overflow: hidden;
            overflow-y: auto;
            flex-shrink: 1;
            flex-grow: 1;
            .iframe {
                width: 100%;
                height: 98%;
                border: none;
            }
        }
    }

    @media screen and (min-width: 1200px) {
        .member-bpus-index {
            max-width: 98%;
        }
    }

    @media screen and (min-width: 1500px) {
        .member-bpus-index {
            max-width: 1400px;
        }
    }
    @media screen and (min-width: 1700px) {
        .member-bpus-index {
            max-width: 1600px;
        }
    }
    @media screen and (min-width: 1800px) {
        .member-bpus-index {
            max-width: 1700px;
        }
    }
</style>
